package com.mc.lp.database.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.mc.lp.database.dao.IExtraAcademicRecordDAO;
import com.mc.lp.database.entity.ExtraAcademicRecordEntity;
/*
 * @author aphanda
 * @date Sep 21, 2014
 * @time 12:57:16 AM
 */

@Repository
public class ExtraAcademicRecordDAOImpl extends
AbstractGenericHibernateDAO<ExtraAcademicRecordEntity, Long, IExtraAcademicRecordDAO> implements
IExtraAcademicRecordDAO{

	private static final long serialVersionUID = 1L;

	@Override
	public void saveExtraAcademics(ExtraAcademicRecordEntity e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<ExtraAcademicRecordEntity> fetchDetailsByEntityIdGrade(Long entityId, int gradeId) {
		
		List<ExtraAcademicRecordEntity> extraAcadList = new ArrayList<ExtraAcademicRecordEntity>();
		Criteria crit = this.getCurrentSession().createCriteria(ExtraAcademicRecordEntity.class);
		crit.add(Restrictions.eq("gradeId", gradeId));
		crit.add(Restrictions.eq("studentEntity",entityId));
		extraAcadList = (List<ExtraAcademicRecordEntity>)crit.list();
		return extraAcadList;
	}

	@Override
	public List<ExtraAcademicRecordEntity> fetchExtraAcademicsByGrades(Long studentEntity,
			List<Integer> gradeValueList) throws DataAccessException {
		List<ExtraAcademicRecordEntity> acadList = new ArrayList<ExtraAcademicRecordEntity>();
		Criteria crit = getCurrentSession().createCriteria(ExtraAcademicRecordEntity.class);
		crit.add(Restrictions.in("gradeId", gradeValueList));
		crit.add(Restrictions.eq("studentEntity",studentEntity));
		acadList = crit.list();
		return acadList;
	}
	
}
